/*
 * @Author: your name
 * @Date: 2020-09-01 11:25:18
 * @LastEditTime: 2020-09-01 11:29:49
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /express/src/controller/CrowllerController.ts
 */
import { Request, Response } from 'express';
import { controller, get, post} from './decorator';
import Crowller from '../utils/crowller';
import Analyzer from '../utils/moke/analyzer';
import { getResponseData } from '../utils/util';

interface BodyRequest extends Request {
  body: { [key: string]: string | undefined };
}

@controller
class CrowllerController {
  @get('/getData')
  getData(req: BodyRequest, res: Response) {
    const secret = 'x3b174jsx';
    const url = `http://www.dell-lee.com/typescript/demo.html?secret=${secret}`;
    const writeFilePath = '../../data/course.json'
    const analyzer = Analyzer.getInstance();
    new Crowller(url, writeFilePath, analyzer);
    res.json(getResponseData(true));
  }
}
